package com.example.servicewallet.controller;


import com.example.servicewallet.service.TWalletService;
import com.example.servicewallet.utils.R;
import com.example.servicewallet.vo.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author admin
 * @since 2023-02-08
 */
@RestController
@RequestMapping("/servicewallet/t-wallet")
@Api(description = "用户钱包钱包模块")
public class TWalletController {

    @Autowired
    private TWalletService walletService;

    /**
     * 绑定钱包
     * @param registerWalletVo
     * @return
     */
    @ApiOperation(value = "绑定钱包")
    @PostMapping("bindWallet")
    public R bindWallet(@RequestBody RegisterWalletVo registerWalletVo) {
        walletService.bindWallet(registerWalletVo);
        return R.ok();
    }

    /**
     * 钱包充值
     */
    @ApiOperation(value = "充值钱包")
    @PostMapping("recharge")
    public R recharge(@RequestBody RechargeVo rechargeVo) {
        Map<String, Object> map = walletService.rechargeWallet(rechargeVo);
        return R.ok().data(map);
    }

    /**
     * 查询余额
     */
    @ApiOperation(value = "查询余额")
    @GetMapping("searchBalance")
    public R recharge(BalanceVo balanceVo) {
        Map<String, Object> map = walletService.searchBalance(balanceVo);
        return R.ok().data(map);
    }

    /**
     * 消费金额
     */
    @ApiOperation(value = "消费金额")
    @PostMapping("payMoney")
    public R payMoney(PayWalletVo payWalletVo) {
        Map<String, Object> map = walletService.payWallet(payWalletVo);
        return R.ok().data(map);
    }

    /**
     * 退款金额
     */
    @ApiOperation(value = "退款金额")
    @PostMapping("returnMoney")
    public R retrunMoney(ReturnWalletVo returnWalletVo) {
        Map<String, Object> map = walletService.returnWallet(returnWalletVo);
        return R.ok().data(map);
    }

    /**
     * 查询钱包明细
     */
    @ApiOperation(value = "查询钱包明细")
    @GetMapping("selectAll")
    public R selectAll(SelectVo selectVo) {
        Map<String, Object> map = walletService.selectAll(selectVo);
        return R.ok().data(map);
    }
}

